-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve documentation on duplex.rs #15182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@schmee Nice idea. It's possible to make an internal link in the documentation? |
pub fn send(&self, x: S) { | ||
self.tx.send(x) | ||
} | ||
|
||
/// Send optionnaly data to the channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misspelling, and I'd say "Optionally send data to the channel."
I do think that this could be even better, but it's a great start, especially with a running example. |
Yep I will add commits until it's done. Thanks for reviews. |
pub fn send(&self, x: S) { | ||
self.tx.send(x) | ||
} | ||
|
||
/// Optionally send data to the channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were unsure what send_opt
did, this documentation doesn't really help me much because it just takes the 8-letter method name and expands it to a bit of english.
If we're adding documentation to these methods, then this should document the semantics of why it exists, what's optional about it, etc. This also applies to the documentation below as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Examples (preferably both the Ok
and Err
cases) would help.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an example and will try to adapt documentation from both Sender and Receiver for DuplexStream.
I am totally agree with you that just putting a sentence is not meaningful. :)
/// std::io::timer::sleep(1000); | ||
/// assert_eq!(left.send_opt("ABC".to_string()), | ||
/// Err("ABC".to_string())); | ||
/// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is definitely helpful, but I think it still needs to be accompanied with words explaining the semantics of this function. The nonstandard functions below should also receive the same treatment.
Additionally, relying on sleep
for correctness is likely to go wrong quickly. You can probably do this in a single-threaded situation without extra tasks.
Due to a future deprecation (see 58133ae) of this file I close this pull-request. |
Disable mir interpreter for targets with different pointer size from host fix rust-lang#15182
Adding example and short documentation for methods.